﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Liger.Web.Common;
using Liger.Web.Common.Extensions;

namespace Liger.Web.UI
{
    public class TreeBuilder : UIComponentBuilderBase, IHideObjectMembers
    {
        private Tree Tree
        {
            get
            {
                return this.Component as Tree;
            }
        }


        public TreeBuilder()
            : base(new Tree())
        {

        }

        public TreeBuilder(Tree Tree)
            : base(Tree)
        {

        }

        /// <summary>
        /// 设置属性
        /// </summary>
        /// <param name="property"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public TreeBuilder Set(string property, object value)
        {
            if (this.Tree.Properties.ContainsKey(property))
            {
                this.Tree.Properties[property] = value;
            }
            else
            {
                this.Tree.Properties.Add(property, value);
            }
            return this;
        }

        /// <summary>
        /// 返回ligerTree的Manager
        /// </summary>
        /// <param name="manager">manager的对象名</param>
        /// <returns></returns>
        public TreeBuilder Manager(string manager)
        {
            this.Tree.Manager = manager;
            return this;
        }



        public TreeBuilder Url(string value)
        {
            this.Tree.Url = value;
            return this;
        }
        public TreeBuilder Data(object value)
        {
            this.Tree.Data = value;
            return this;
        }
        public TreeBuilder Checkbox(bool value)
        {
            this.Tree.Checkbox = value;
            return this;
        }
        public TreeBuilder AutoCheckboxEven(bool value)
        {
            this.Tree.AutoCheckboxEven = value;
            return this;
        }
        public TreeBuilder ParentIcon(string value)
        {
            this.Tree.ParentIcon = value;
            return this;
        }
        public TreeBuilder ChildIcon(string value)
        {
            this.Tree.ChildIcon = value;
            return this;
        }
        public TreeBuilder TextFieldName(string value)
        {
            this.Tree.TextFieldName = value;
            return this;
        }
        public TreeBuilder Attribute(List<string> value)
        {
            this.Tree.Attribute = value;
            return this;
        }
        public TreeBuilder TreeLine(bool value)
        {
            this.Tree.TreeLine = value;
            return this;
        }
        public TreeBuilder NodeWidth(int value)
        {
            this.Tree.NodeWidth = value;
            return this;
        }
        public TreeBuilder StatusName(string value)
        {
            this.Tree.StatusName = value;
            return this;
        }
        //是否叶节点
        public TreeBuilder IsLeaf(Func<string> value)
        {
            this.Tree.IsLeaf = value;
            return this;
        }
        /// <summary>
        /// 是否单选
        /// </summary>
        public TreeBuilder Single(bool value)
        {
            this.Tree.Single = value;
            return this;
        }
        public TreeBuilder IdFieldName(string value)
        {
            this.Tree.IdFieldName = value;
            return this;
        }
        public TreeBuilder ParentIDFieldName(string value)
        {
            this.Tree.ParentIDFieldName = value;
            return this;
        }

        /// <summary>
        /// 是否以动画的形式显示
        /// </summary>
        public TreeBuilder Slide(bool value)
        {
            this.Tree.Slide = value;
            return this;
        }
        public TreeBuilder IconFieldName(string value)
        {
            this.Tree.IconFieldName = value;
            return this;
        }
        public TreeBuilder NodeDraggable(bool value)
        {
            this.Tree.NodeDraggable = value;
            return this;
        }

        public TreeBuilder NodeDraggingRender(Func<string> value)
        {
            this.Tree.NodeDraggingRender = value;
            return this;
        }
        public TreeBuilder BtnClickToToggleOnly(bool value)
        {
            this.Tree.BtnClickToToggleOnly = value;
            return this;
        }
    }
}